#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "controltypeform.h"
#include "loginform.h"
#include "robotlistform.h"
#include "sitelistform.h"
#include "robotcontrolform.h"
#include <QMainWindow>
#include <webrtc/webrtcwidget.h>


QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class UrdfWidget;
class SlamWidget;
class MainWindow : public QMainWindow
{
    Q_OBJECT
public:
    static MainWindow * getInstance();
    static void Release();
    ~MainWindow();

    UrdfWidget *pUrdfWidget();

    QWidget *pMapWidget();

    QWidget *pCloundWidget();

    VideoBase * pVideoWidget(QString strUrl);
    double getScale();
protected:
    void showWidget(QWidget * pWidget);
    void scaleWidgets(QWidget *widget, double xScale,double yScale);
private:
    Ui::MainWindow *ui;
    //登录界面
    LoginForm * m_pLoginForm = NULL;
    //选择控制类型界面
    ControlTypeForm * m_pCtrlTypeForm = NULL;
    //机器人列表界面
    RobotListForm * m_pRobotListForm = NULL;
    //训练场列表界面
    SiteListForm * m_pSiteListForm = NULL;
    //机器人控制界面
    RobotControlForm * m_pRobotControlForm = NULL;

public slots:
    void onOrrorOccurred(const QString& error);
    void onControlStateChanged(bool controlled);
    // QWidget interface
protected:
    void resizeEvent(QResizeEvent *event);

    MainWindow(QWidget *parent = nullptr);
    static MainWindow * m_pInstance;

    QMap<QString,VideoBase *> m_mpVideoWidget;
    UrdfWidget * m_pUrdfWidget;
    SlamWidget *  m_pMapWidget;
    QWidget * m_pCloundWidget;

};
#endif // MAINWINDOW_H
